package com.hspedu.enum_;

/**
 * 自定义枚举类
 * @author sp
 * @version 0.1
 */
public class Enumeration02 {
    public static void main(String[] args) {
        System.out.println(CustomizeSeason.SPRING.getName());
    }
}

class CustomizeSeason {
    private String name;
    private String desc;

    //自定义枚举改造
    //1.私有化构造器防止被新建新对象
    private CustomizeSeason(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    //2.去掉setter方法，防止属性被修改
    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    //3.在Season内部，直接创建固定的对象
    //4.可以加上final修饰符优化
    public static final CustomizeSeason SPRING = new CustomizeSeason("春天", "温暖");
    public static final CustomizeSeason SUMMER = new CustomizeSeason("夏天", "炎热");
    public static final CustomizeSeason AUTUMN = new CustomizeSeason("秋天", "凉爽");
    public static final CustomizeSeason WINTER = new CustomizeSeason("冬天", "寒冷");
}